<template>
    <div ref="parent" class="gamemap">
        <canvas ref="canvas"  tabindex="0">
        </canvas>
    </div>
</template>

<script>
import { GameMap } from "@/assets/scripts/GameMap2"//这里变
import { ref, onMounted } from 'vue'
import { useStore } from 'vuex';
// import { Tank } from "@/assets/scripts/Tank"//这里变

export default {
    setup() {
        let parent = ref(null);
        let canvas = ref(null);

        let store = useStore();
        


        onMounted(() => {
            store.commit(
                "updateGameObject",
                new GameMap(canvas.value.getContext('2d'), parent.value, store)
            );//创建对象的同时，把它存到全局变量里面
        });
        return {
            parent,
            canvas
        }
    }
}

</script>


<style scoped>

    div.gamemap {
        width: 100%;
        height: 100%;
        display: flex;
        justify-content: center;
        align-items: center;
    }
</style>